const sysService = require('../services/sysService')
const { decodeToken } = require('../utils/jwt')
async function getLogin(ctx) {
    const data = ctx.request.body
    console.log('data', data)
    ctx.body = await sysService.getLoginByAccount(data)
}

async function findByPhone(ctx) {
    // 从token中解析出phone
    const { phone } = ctx.state.user
    console.log('🚀 ~ findByPhone ~ ctx:', phone)
    ctx.body = await sysService.getByUserInfoByPhone(phone)
}

async function createUser(ctx) {
    const data = ctx.request.body
    ctx.body = await userService.create(data)
}

async function getChapCode(ctx) {
    const params = ctx.params
    ctx.body = await sysService.handleChapCode(params)
}
async function uploadFile(ctx) {
    ctx.body = await sysService.handleUploadFile(ctx)
}

async function updateUserInfo(ctx) {
    ctx.body = await sysService.handleUpdateUserInfo(ctx)
}

module.exports = { getLogin, findByPhone, createUser, getChapCode, uploadFile, updateUserInfo }
